<?php

/**
 * This is the model class for table "objek_pajak".
 *
 * The followings are the available columns in table 'objek_pajak':
 * @property string $no_op
 * @property string $kode_kel
 * @property string $kode_jns
 * @property string $kode_blok
 * @property string $nama_pmk
 * @property string $alamat_pmk
 * @property string $kab_pmk
 * @property string $nik_pmk
 * @property string $rt_pmk
 * @property string $rw_pmk
 * @property string $kel_pmk
 * @property string $kec_pmk
 * @property string $kodepos_pmk
 * @property string $lokasi_op
 * @property string $rt_op
 * @property string $rw_op
 * @property string $kota_op
 * @property double $luas_tan
 * @property double $njop_tan
 * @property double $nilai_tan
 * @property double $luas_tanbng
 * @property double $njop_tanbng
 * @property double $nilai_tanbng
 * @property double $tot_nilai
 * @property double $hrg_taksir
 * @property string $no_sertf
 * @property string $tgl_prs
 * @property string $tahun
 * @property integer $sts_rec
 * @property string $sts_png
 * @property string $sts_blok
 * @property string $kode_user
 *
 * The followings are the available model relations:
 * @property Kelurahan $kodeKel
 * @property Users $kodeUser
 * @property JenisPrh $kodeJns
 * @property Pengalihan[] $pengalihans
 * @property DokTerima[] $dokTerimas
 * @property LapPpat[] $lapPpats
 * @property WajibPajak[] $wajibPajaks
 * @property Blokir[] $blokirs
 */
class ObjekPajak extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'objek_pajak';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kode_user', 'required'),
			array('sts_rec', 'numerical', 'integerOnly'=>true),
			array('luas_tan, njop_tan, nilai_tan, luas_tanbng, njop_tanbng, nilai_tanbng, tot_nilai, hrg_taksir', 'numerical'),
			array('no_op', 'length', 'max'=>18),
			array('kode_kel, kodepos_pmk', 'length', 'max'=>7),
			array('kode_jns, kode_blok, rt_pmk, rw_pmk, rt_op, rw_op', 'length', 'max'=>3),
			array('nama_pmk, lokasi_op', 'length', 'max'=>35),
			array('alamat_pmk', 'length', 'max'=>50),
			array('kab_pmk, kel_pmk, kec_pmk, kota_op', 'length', 'max'=>25),
			array('nik_pmk', 'length', 'max'=>16),
			array('no_sertf', 'length', 'max'=>15),
			array('tahun', 'length', 'max'=>4),
			array('sts_png, sts_blok', 'length', 'max'=>1),
			array('kode_user', 'length', 'max'=>8),
			array('tgl_prs', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('no_op, kode_kel, kode_jns, kode_blok, nama_pmk, alamat_pmk, kab_pmk, nik_pmk, rt_pmk, rw_pmk, kel_pmk, kec_pmk, kodepos_pmk, lokasi_op, rt_op, rw_op, kota_op, luas_tan, njop_tan, nilai_tan, luas_tanbng, njop_tanbng, nilai_tanbng, tot_nilai, hrg_taksir, no_sertf, tgl_prs, tahun, sts_rec, sts_png, sts_blok, kode_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kodeKel' => array(self::BELONGS_TO, 'Kelurahan', 'kode_kel'),
			'kodeUser' => array(self::BELONGS_TO, 'Users', 'kode_user'),
			'kodeJns' => array(self::BELONGS_TO, 'JenisPrh', 'kode_jns'),
			'pengalihans' => array(self::HAS_MANY, 'Pengalihan', 'no_op'),
			'dokTerimas' => array(self::HAS_MANY, 'DokTerima', 'no_op'),
			'lapPpats' => array(self::HAS_MANY, 'LapPpat', 'no_op'),
			'wajibPajaks' => array(self::HAS_MANY, 'WajibPajak', 'no_op'),
			'blokirs' => array(self::HAS_MANY, 'Blokir', 'no_op'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'no_op' => 'No Op',
			'kode_kel' => 'Kode Kel',
			'kode_jns' => 'Kode Jns',
			'kode_blok' => 'Kode Blok',
			'nama_pmk' => 'Nama Pmk',
			'alamat_pmk' => 'Alamat Pmk',
			'kab_pmk' => 'Kab Pmk',
			'nik_pmk' => 'Nik Pmk',
			'rt_pmk' => 'Rt Pmk',
			'rw_pmk' => 'Rw Pmk',
			'kel_pmk' => 'Kel Pmk',
			'kec_pmk' => 'Kec Pmk',
			'kodepos_pmk' => 'Kodepos Pmk',
			'lokasi_op' => 'Lokasi Op',
			'rt_op' => 'Rt Op',
			'rw_op' => 'Rw Op',
			'kota_op' => 'Kota Op',
			'luas_tan' => 'Luas Tan',
			'njop_tan' => 'Njop Tan',
			'nilai_tan' => 'Nilai Tan',
			'luas_tanbng' => 'Luas Tanbng',
			'njop_tanbng' => 'Njop Tanbng',
			'nilai_tanbng' => 'Nilai Tanbng',
			'tot_nilai' => 'Tot Nilai',
			'hrg_taksir' => 'Hrg Taksir',
			'no_sertf' => 'No Sertf',
			'tgl_prs' => 'Tgl Prs',
			'tahun' => 'Tahun',
			'sts_rec' => 'Sts Rec',
			'sts_png' => 'Sts Png',
			'sts_blok' => 'Sts Blok',
			'kode_user' => 'Kode User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('no_op',$this->no_op,true);
		$criteria->compare('kode_kel',$this->kode_kel,true);
		$criteria->compare('kode_jns',$this->kode_jns,true);
		$criteria->compare('kode_blok',$this->kode_blok,true);
		$criteria->compare('nama_pmk',$this->nama_pmk,true);
		$criteria->compare('alamat_pmk',$this->alamat_pmk,true);
		$criteria->compare('kab_pmk',$this->kab_pmk,true);
		$criteria->compare('nik_pmk',$this->nik_pmk,true);
		$criteria->compare('rt_pmk',$this->rt_pmk,true);
		$criteria->compare('rw_pmk',$this->rw_pmk,true);
		$criteria->compare('kel_pmk',$this->kel_pmk,true);
		$criteria->compare('kec_pmk',$this->kec_pmk,true);
		$criteria->compare('kodepos_pmk',$this->kodepos_pmk,true);
		$criteria->compare('lokasi_op',$this->lokasi_op,true);
		$criteria->compare('rt_op',$this->rt_op,true);
		$criteria->compare('rw_op',$this->rw_op,true);
		$criteria->compare('kota_op',$this->kota_op,true);
		$criteria->compare('luas_tan',$this->luas_tan);
		$criteria->compare('njop_tan',$this->njop_tan);
		$criteria->compare('nilai_tan',$this->nilai_tan);
		$criteria->compare('luas_tanbng',$this->luas_tanbng);
		$criteria->compare('njop_tanbng',$this->njop_tanbng);
		$criteria->compare('nilai_tanbng',$this->nilai_tanbng);
		$criteria->compare('tot_nilai',$this->tot_nilai);
		$criteria->compare('hrg_taksir',$this->hrg_taksir);
		$criteria->compare('no_sertf',$this->no_sertf,true);
		$criteria->compare('tgl_prs',$this->tgl_prs,true);
		$criteria->compare('tahun',$this->tahun,true);
		$criteria->compare('sts_rec',$this->sts_rec);
		$criteria->compare('sts_png',$this->sts_png,true);
		$criteria->compare('sts_blok',$this->sts_blok,true);
		$criteria->compare('kode_user',$this->kode_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return ObjekPajak the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
